--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_joutougu_mayumi = General:new(extension, "hy_joutougu_mayumi", "chi_k", 4, 4, General.Female)
    local special_operation = fk.CreateSkill {
        name = "special_operation",
    }
    special_operation:addEffect(fk.EventPhaseStart, {
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(self) and target ~= player and target.phase == Player.Start and #target:getAvailableEquipSlots() > 0 and #player:getCardIds("he") > 0
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            event:setCostData(self, room:askToDiscard(player, {
                min_num = 1,
                max_num = 1,
                include_equip = true,
                skill_name = special_operation.name,
                prompt = "special_operation_prompt::" .. target.id,
                skip = true,
            }))
            return #event:getCostData(self) > 0
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local result = room:askToChoice(player, {
                choices = target:getAvailableEquipSlots(),
                skill_name = special_operation.name,
                prompt = "special_operation_prompt_choice::" .. target.id,
                all_choices = target.equipSlots,
                cancelable = false,
            })
            room:throwCard(event:getCostData(self), special_operation.name, player, player)
            room:abortPlayerArea(target, result)
            local mark = target:getTableMark("special_operation")
            table.insert(mark, result)
            room:setPlayerMark(target, "special_operation", mark)
            local card = Fk:getCardById(event:getCostData(self)[1])
            if room:askToSkillInvoke(player, {
                    skill_name = special_operation.name,
                    prompt = "special_operation_prompt_slash::" .. target.id
                }) then
                room:useCard({
                    from = player,
                    tos = { target },
                    card = Fk:cloneCard("slash"),
                    extraUse = true,
                })
            end
            if card.type ~= Card.TypeEquip then
                room:addPlayerMark(target, "special_operation-turn", 2)
            end
        end,
    })
    special_operation:addEffect(fk.TurnEnd, {
        priority = 0.01,
        can_refresh = function(self, event, target, player, data)
            return #player:getTableMark("special_operation") > 0 and target == player
        end,
        on_refresh = function(self, event, target, player, data)
            local room = player.room
            room:resumePlayerArea(player, player:getTableMark("special_operation"))
            room:setPlayerMark(player, "special_operation", 0)
        end
    })
    special_operation:addEffect("atkrange", {
        correct_func = function(self, from, to)
            return from:getMark("special_operation-turn")
        end,
    })
    local weaponized_idol = fk.CreateSkill {
        name = "weaponized_idol",
    }
    weaponized_idol:addEffect(fk.Damage, {
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(self) and data.from and data.from == player and data.to ~= player and not table.contains(player:getTableMark("weaponized_idol"), data.to.id) and
                (#table.filter(data.to:getCardIds("e"), function(id)
                    return Fk:getCardById(id).type == Card.TypeEquip
                end) > 0 or #table.filter(player.room.discard_pile, function(id)
                    return Fk:getCardById(id).type == Card.TypeEquip
                end) > 0)
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            local choices = { "weaponized_idol_equip1", "weaponized_idol_equip2", "Cancel" }
            local valid = table.clone(choices)
            if #table.filter(data.to:getCardIds("e"), function(id)
                    return Fk:getCardById(id).type == Card.TypeEquip
                end) == 0 then
                table.removeOne(valid, "weaponized_idol_equip1")
            end
            if #table.filter(room.discard_pile, function(id)
                    return Fk:getCardById(id).type == Card.TypeEquip
                end) == 0 then
                table.removeOne(valid, "weaponized_idol_equip2")
            end
            local result = room:askToChoice(player, {
                choices = valid,
                skill_name = weaponized_idol.name,
                prompt = "weaponized_idol_prompt",
                all_choices = choices,
            })
            if result == "weaponized_idol_equip1" then
                local card = room:askToChooseCard(player, {
                    target = data.to,
                    flag = "e",
                    skill_name = weaponized_idol.name
                })
                event:setCostData(self, card)
            elseif result == "weaponized_idol_equip2" then
                event:setCostData(self, table.random(table.filter(room.discard_pile, function(id)
                    return Fk:getCardById(id).type == Card.TypeEquip
                end)))
            end
            return result ~= "Cancel"
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            room:obtainCard(player, event:getCostData(self), true, fk.ReasonPrey, player, weaponized_idol.name)
            local mark = player:getTableMark("weaponized_idol")
            table.insertIfNeed(mark, data.to.id)
            room:setPlayerMark(player, "weaponized_idol", mark)
            room:setPlayerMark(player, "@&weaponized_idol", table.map(mark, function(id)
                return room:getPlayerById(id).general
            end))
        end,
    })
    extension:loadSkillSkels { special_operation, weaponized_idol }
    hy_joutougu_mayumi:addSkill("special_operation")
    hy_joutougu_mayumi:addSkill("weaponized_idol")
    Fk:loadTranslationTable {
        ["hy_joutougu_mayumi"] = "杖刀偶磨弓",
        ["#hy_joutougu_mayumi"] = "万兵之首",
        ["designer:hy_joutougu_mayumi"] = "黑曜人形",
        ["illustrator:hy_joutougu_mayumi"] = "ねるぞう",
        ["cv:hy_joutougu_mayumi"] = "",

        ["special_operation"] = "特战",
        [":special_operation"] = "其他角色的准备阶段，你可以弃置一张牌并<a href = 'temp_operation'>临时</a>废除其一个装备栏直到本回合结束，然后你可以视为对其使用一张无距离限制的【杀】。若你以此法弃置了非装备牌，其本回合攻击范围+2。",
        ["special_operation_prompt"] = "特战：你可以弃置一张牌并废除%dest一个装备栏",
        ["special_operation_prompt_choice"] = "特战：废除%dest一个装备栏",
        ["special_operation_prompt_slash"] = "特战：你可以视为对%dest使用一张【杀】",

        ["weaponized_idol"] = "军偶",
        [":weaponized_idol"] = "每名角色限一次，在你对其他角色造成伤害后，你可以选择一项：1.获得其装备区一张装备牌；2.获得弃牌堆随机一张装备牌。",
        ["weaponized_idol_prompt"] = "军偶：你可以选择一项",
        ["weaponized_idol_equip1"] = "获得其装备",
        ["weaponized_idol_equip2"] = "获得弃牌堆装备",
        ["@&weaponized_idol"] = "军偶",
    }
end
